package com.example.myapplication;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.TextView;

import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.example.myapplication.adapter.MainVpAdapter;

public class FragmentActivity extends AppCompatActivity {
    private TextView newsView,mineView,homeView;
    private ViewPager mVp;
    private MainVpAdapter mainVpAdapter;
    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_fragment);
        mVp = findViewById(R.id.vp_content);
        homeView = findViewById(R.id.tv_home);
        newsView = findViewById(R.id.tv_news);
        mineView = findViewById(R.id.tv_mine);
        mainVpAdapter = new MainVpAdapter(getSupportFragmentManager());
        mVp.setAdapter(mainVpAdapter);
        homeView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mVp.setCurrentItem(0);
            }
        });
        newsView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mVp.setCurrentItem(1);
            }
        });
        mineView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mVp.setCurrentItem(2);
            }
        });

//        Log.e("tag","onCreate");
//        topFragment = new DemoFragment();
//        bottomFragment = new DemoFragment();
//        getFragmentManager().beginTransaction().replace(R.id.ll_top_f1,topFragment).commit();
//        getFragmentManager().beginTransaction().replace(R.id.ll_bottom_f1,bottomFragment).commit();
    }



}
